<?php
/**
 * @version		0.2.0 joomla zmluvy $
 * @package		com_zjmluvy
 * @copyright	Copyright © 2011 - All rights reserved.
 * @license		GNU/GPL
 * @author    AdrianKo		
 * @website   http://code.google.com/p/joomla-zmluvy
 *
 *
 *1.3.2012
 */

// no direct access
defined('_JEXEC') or die('Restricted access');
?>

<?php  JHTML::_('behavior.tooltip');  ?>

<?php

	JToolBarHelper::title( JText::_( '&nbsp;&nbsp;&nbsp;'.JText::_( 'title_ZMLUVY' ) ), 'zmluvy' );
	JToolBarHelper::addNew();
	JToolBarHelper::editListX();
  JToolBarHelper::deleteList();
//	JToolBarHelper::preferences('com_jzmluvy', '500');
//	JToolBarHelper::help( 'screen.users' );
  $params	= &JComponentHelper::getParams('com_jzmluvy');

?>
<form action="index.php?option=com_jzmluvy" method="post" name="adminForm">
	<table>
		<tr>
			<td width="100%">
				<?php echo JText::_( 'FILTER' ); ?>:
				<input type="text" name="search" id="search" value="<?php echo htmlspecialchars($this->lists['search']);?>" class="text_area" onchange="document.adminForm.submit();" />
				<button onclick="this.form.submit();"><?php echo JText::_( 'POUZI' ); ?></button>
				<button onclick="document.getElementById('search').value='';this.form.getElementById('filter_type').value='0';this.form.getElementById('filter_logged').value='0';this.form.submit();"><?php echo JText::_( 'ZRUSIT' ); ?></button>
			</td>
			<td nowrap="nowrap">
				<?php //echo $this->lists['anotace'];?>
        <?php // echo $this->lists['archiv'];?>
        <?php // echo $this->lists['kategorie'];?>				
			</td>
		</tr>
	</table>

	<table class="adminlist" cellpadding="1">
		<thead>
			<tr>
				<th width="2%" class="title">
					<?php echo JText::_( 'PORADIE' ); ?>
				</th>
				<th width="3%" class="title">
					<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($this->items); ?>);" />
				</th>
				<th width="6%" class="title" nowrap="nowrap">
					<?php echo JHTML::_('grid.sort',   JText::_( 'ZM_EDIT_DAT_UZAVRETIA' ), 'ud.datUhrady', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
				</th>
        <th width="6%" class="title" nowrap="nowrap">
					<?php echo JHTML::_('grid.sort',   JText::_( 'ZM_EDIT_DAT_ZVEREJNENIA' ), 'ud.datZver', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
				</th>
        <th width="3%" class="title" nowrap="nowrap">
					<?php echo JHTML::_('grid.sort',   JText::_( 'ZM_CISLO_ZMLUVY_LOM' ), 'ud.faktura', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
				</th>
				<th width="40%" class="title" >
					<?php echo JHTML::_('grid.sort',   JText::_( 'ZM_EDIT_PREDMET' ), 'ud.title', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
				</th>
        <th width="10%" class="title" >
					<?php echo JHTML::_('grid.sort',   JText::_( 'fa_EDIT_SUMA' ), 'ud.suma', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
				 <?php if($this->nastavenie->dph) { echo JText::_( 'OBJ_SDPH' ); } else { echo JText::_( 'OBJ_BEZDPH' ); } ?>
        </th>
        <th width="5%" class="title" >
					<?php echo JHTML::_('grid.sort',   JText::_( 'ZM_EDIT_TYP' ), 'ud.typ', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
				</th>
				<th class="title" nowrap="nowrap">
					<?php echo JHTML::_('grid.sort',   JText::_( 'ZM_EDIT_UCASTNIK_ZMLUVY' ), 'ud.dodavatel', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
				</th>                                         
				<th width="8%" class="title">
          <?php echo JText::_( 'fa_SUBOR' ); ?>
				</th>
				<!--
        <th width="5%" class="title">
					<?php echo JText::_( 'fa_STIAHNUTE' ); ?>
				</th> -->
        <?php if($this->params->get('debug')) : ?>
				<th width="3%" class="title" nowrap="nowrap">
					<?php echo JHTML::_('grid.sort',   'ID', 'ud.id', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
				</th><?php endif; ?>
			</tr>
		</thead>
		<tfoot>
			<tr>
				<td colspan="11">
					<?php echo $this->pagination->getListFooter(); ?>
				</td>
			</tr>
		</tfoot>
<tbody>
		<?php
			$k = 0;
			for ($i=0, $n=count( $this->items ); $i < $n; $i++)
			{
				$row 	=& $this->items[$i];
				$link 	= 'index.php?option=com_jzmluvy&amp;view=upravazmluvy&amp;hidemainmenu=1&amp;task=edit&amp;id[]='. $row->id. '';
        $link2 	= 'index.php?option=com_jzmluvy&amp;view=upravapartner&amp;hidemainmenu=1&amp;task=edit&amp;id[]='. $row->dodavatel. '';
        $link_zml 	= 'index.php?option=com_jzmluvy&amp;view=upravazmluvy&amp;hidemainmenu=1&amp;task=edit&amp;id[]='. $row->sposob_uhrady. '';
			
        // kontola povinnych udajov
        if((empty($row->title)) || (empty($row->fulltext)) || (empty($row->dodavatel)) || (empty($row->mena)) || (empty($row->datUhrady)) || ($row->datUhrady == 0) || (empty($row->datZver)))
        {
        $chyba = jzmluvyHelper::obrazok('chyba-16.png','',JText::_( 'pa_chybny' ));
        }
        else 
        {
        $chyba = "";
        } 
        
      ?>
			<tr class="<?php echo "row$k"; ?>">
				<td>
					<?php echo $i+1+$this->pagination->limitstart;?>
				</td>
				<td>
					<?php echo JHTML::_('grid.id', $i, $row->id, '', 'id'); ?>
				</td>

				<td  align="right">
          <?php echo jzmluvyHelper::datdmy($row->datUhrady); ?>
				</td>
        				<td  align="right">
          <?php echo jzmluvyHelper::datdmy($row->datZver); ?>
				</td>
				<td>
           <?php echo $row->faktura; ?>
				</td>
        <td><?php echo $chyba; ?>
           <a href="<?php echo $link; ?>">
						<?php echo $row->fulltext; ?></a>
					<div style="padding-left: 10px"><?php echo $row->title; ?></div>
				</td>
					<td  align="right">
					<?php echo jzmluvyHelper::format_number($row->suma,',',' ')." ".$row->mena ?>
				</td>
   			<td >
					<?php if(empty($row->zml_text)) { $zmluva = $row->zml_text2; } else { $zmluva = $row->zml_text; } ?>
          <?php echo $this->typ_fak_dod($row->typ)."<br /><a href='".$link_zml."' alt=''>".$zmluva."</a>"; ?>
				</td>
        <td  nowrap="nowrap">
        <a href="<?php echo $link2; ?>">
        <?php echo $row->fadod; ?></a>    </td>
        <td align="center"><?php if (!empty($row->file)) echo $this->soubor ($row->id,$row->file,$row->filename,$row->extension); ?>
        <?php if (!empty($row->file2)) echo " ".$this->soubor2 ($row->id,$row->file2,$row->filename2,$row->extension2); ?>
        </td>
        <!-- <td align="center"><?php echo $row->hits.'x,'.$row->hits2.'x'; ?></td> -->
				<!-- <td><?php echo $row->catitle; ?></td> -->
         <?php if($this->params->get('debug')) : ?>
         <td>
					<?php echo $row->id; ?>
				</td><?php endif; ?>
			</tr>
			<?php
				$k = 1 - $k;
				}
			?>
		</tbody>
	</table>
		<input type="hidden" name="option" value="com_jzmluvy" />
		<input type="hidden" name="view" value="zmluva" />
		<input type="hidden" name="controller" value="upravazmluvy" />
		<input type="hidden" name="boxchecked" value="0" />
		<input type="hidden" name="task" value="" />
		<input type="hidden" name="redirect" value="<?php //echo $redirect; ?>" />
		<input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
    <input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
		<?php echo JHTML::_( 'form.token' ); ?>
	</form>